package com.example.demo.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description:
 * @author: cj
 * @create: 17-12-21 17:42:17
 */
@NoArgsConstructor
@Data
public class Result<T> {
    private int status;
    private String message;
    private T data;

    public Result(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public Result(int status, T data) {
        this.status = status;
        this.data = data;
    }

    public Result(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public static Result error(String message) {
        return new Result( 500, message );
    }
    public static Result error(String message,Integer code) {
        return new Result( code, message );
    }

    public static Result<Object> ok(String message, Object data) {
        return new Result<>( 200, message, data );
    }

    public static Result ok(Object data) {
        return new Result<>( 200, data );
    }
}
